package git.bds.nyc.applet.api.controller.mine;

import git.bds.nyc.applet.api.model.dto.FarmerAuthenticationInfoDTO;
import git.bds.nyc.applet.api.service.attestation.AttestationService;
import git.bds.nyc.result.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 成大事
 * @since 2023/3/11 17:16
 */
@Api(tags = "认证管理接口")
@Slf4j
@Validated
@RestController
@RequestMapping("/applet/mine/attestation")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class AttestationController {


    private final AttestationService attestationService;


    /**
     * 是农民身份验证吗
     *
     * @return {@link R}<{@link Boolean}>
     */
    @ApiOperation(value = "是否认证")
    @PostMapping("/isFarmerAuthentication")
    public R<Boolean> isFarmerAuthentication(){
        return R.ok( attestationService.isFarmerAuthentication());
    }


    /**
     * 农民认证
     *
     * @param infoDTO 信息到
     * @return {@link R}<{@link Boolean}>
     */
    @ApiOperation(value = "农户认证",notes = "只需要上传身份证照片+身份证号+真实名字")
    @PostMapping("/farmerAuthentication")
    public R<Boolean> farmerAuthentication(
            @Validated FarmerAuthenticationInfoDTO infoDTO
    ){
       return R.decide( attestationService.farmerAuthentication(infoDTO));
    }
}
